package com.zitronella.course.osseventmanager.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;

import javax.servlet.http.HttpSession;

import com.zitronella.course.osseventmanager.service.PositionService;
import com.zitronella.course.osseventmanager.service.EventService;

import java.util.Date;

@Controller
@RequestMapping("/events")
public class EventListController{

    private EventService eventService;

    @Autowired
    public void setEventService(EventService evService) {
        this.eventService = evService;
    }

    @RequestMapping(method = RequestMethod.GET)
    public String prepareEventList(Model model, HttpSession session) {
        model.addAttribute("events", eventService.findFutureEvents(new Date()));
        return "events";
    }
}   